package com.java1234.web;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java1234.dao.MessageDao;
import com.java1234.util.DbUtil;
import com.java1234.util.ResponseUtil;

import net.sf.json.JSONObject;

public class MessageConcelConfirmServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	DbUtil dbUtil=new DbUtil();
	MessageDao messageDao=new MessageDao();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String Sid=request.getParameter("id");
		int id=Integer.parseInt(Sid);
		String delIds=request.getParameter("delIds");
		Connection con=null;
		try{
			con=dbUtil.getCon();
			JSONObject result=new JSONObject();
			int delNums=0;
			if(id==0){
				delNums=messageDao.messageConcelConfirm(con, delIds);
			}
			if(id==1){
				delNums=messageDao.messageConcelAllConfirm(con);
			}
			if(delNums>0){
				result.put("success", "true");
				result.put("delNums", delNums);
			}else{
				result.put("errorMsg", "取消立项失败");
			}
			ResponseUtil.write(response, result);
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try {
				dbUtil.closeCon(con);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
